package com.beifu.manager.service.washfeedback.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.beifu.manager.api.domain.feedback.FeedBackParam;
import com.beifu.manager.dao.AssetScrapDetailMapper;
import com.beifu.manager.dao.WashFeedbackRfidsMapper;
import com.beifu.manager.model.WashFeedbackRfids;
import com.beifu.manager.model.WashFeedbackRfidsExample;
import com.beifu.manager.service.washfeedback.WashFeedBackRfidsService;
@Service
public class WashFeedBackRfidsServiceImpl implements WashFeedBackRfidsService {
	@Autowired
	private WashFeedbackRfidsMapper washFeedbackRfidsMapper;
	@Autowired
	private AssetScrapDetailMapper assetScrapDetailMapper;
	
	@Override
	public List<FeedBackParam> getWashFeedBackRfids(Integer washFeedbackId) {
		List<FeedBackParam> list = new ArrayList<FeedBackParam>();
		
		WashFeedbackRfidsExample example = new WashFeedbackRfidsExample();
		example.createCriteria().andWashFeedbackIdEqualTo(washFeedbackId);
		List<WashFeedbackRfids> rfids = washFeedbackRfidsMapper.selectByExample(example);
		if(null != rfids && rfids.size() > 0){
			for (WashFeedbackRfids washFeedbackRfids : rfids) {
				String rfidCode = washFeedbackRfids.getAssetRfidCode();
				FeedBackParam rfidInfo = new FeedBackParam();
				rfidInfo.setRFID(rfidCode);
				
				Map<String, Object> assetType = assetScrapDetailMapper.getTypeName(rfidCode);//获取资产名称和自定义编号
				if(null != assetType){
					rfidInfo.setTypeName((String) assetType.get("typeName"));
					rfidInfo.setTypeId((String) assetType.get("typeId"));
				}
				list.add(rfidInfo);
			}
		}
		return list;
	}

}
